package com.lili.promotion.controller;

import com.lili.common.result.Result;
import com.lili.model.promotion.Coupon;
import com.lili.promotion.service.CouponManagerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/manager/promotion/coupon")
@Api(tags = "促销活动管理端，优惠卷接口")
public class CouponMangerController {
    @Autowired
    private CouponManagerService couponManagerService;

    @GetMapping("/get")
    @ApiOperation(value = "获取优惠卷列表")
    public Result getqueryCouponList(@RequestBody Map map){
        List<Coupon> rs = couponManagerService.query(map);
        return  Result.ok(rs);
    }

    @PostMapping("/add")
    @ApiOperation(value = "添加优惠卷")
    public Result addCoupon(@RequestBody Coupon coupon){
        int save = couponManagerService.save(coupon);
        return Result.ok(save);

    }

    @PostMapping("/update")
    @ApiOperation(value = "修改优惠卷信息")
    public Result updateCoupon(Long id){
        int update = couponManagerService.update(id);
        return Result.ok(update);

    }



}
